package com.example.simplerpc.common.protocol;

/**
 * @Classname: MessageProtocol
 * @Description: 消息协议，定义编组请求、解组请求、编组响应、解组响应规范
 * @Author: Stonffe
 * @Date: 2022/12/19 10:51
 */
public interface MessageProtocol {
    /**
     * 编码请求
     * @param request
     * @return
     * @throws Exception
     */
    byte[] marshallingReqest(RpcRequest request) throws Exception;

    /**
     * 解密请求
     * @param data
     * @return
     * @throws Exception
     */
    RpcRequest unmarshallingRequest(byte[] data) throws Exception;

    /**
     * 编码响应
     * @param response
     * @return
     * @throws Exception
     */
    byte[] marshallingResponse(RpcResponse response) throws Exception;

    /**
     * 解码响应
     * @param data
     * @return
     * @throws Exception
     */
    RpcResponse unmarshallingResponse(byte[] data) throws Exception;
}
